package behavior.Strategy;

/**
 * Created by LYJ on 2016/10/21.
 * 详细链接：Strategy（策略）http://blog.csdn.net/u013256816/article/details/51245046
 */
public class MainTest {
    public static void main(String... args) {
        Context context = null;
        context = new Context(new ConcreteStrategyA());
        context.doOperate();
        context = new Context(new ConcreteStrategyB());
        context.doOperate();
        context = new Context(new ConcreteStrategyC());
        context.doOperate();

        //因为Strategy是函数式接口，所以采用lambda的方式可以避免采用策略设计模式时僵化的模板代码
        context=new Context(()-> System.out.println("初入东吴。。"));
        context.doOperate();


    }
}
